<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>易购商城-登录</title>
    <link rel="stylesheet" th:href="@{css/common.css}">
    <link rel="stylesheet" th:href="@{styles/login.css}">
    <link rel="stylesheet" th:href="@{styles/header.css}">
    <link rel="stylesheet" th:href="@{sweetalert/sweetalert.css}"/>
</head>
<body>
<div class="top center">
    <div class="logo center">
        <a href="./index.html" target="_blank"><img src="image/login-logo-2-medium.png" alt="" style="max-height: 72%"></a>
    </div>
</div>
<div class="form center">
    <!--<div class="video">-->
        <!--<video src="video/video.mp4" muted loop autoplay style="width: 500px"></video>-->
    <!--</div>-->
    <div class="login">

        <div class="login_center">
            <div class="login_top">
                <div class="left fl">会员登录</div>
                <div class="right fr">您还不是我们的会员？<a href="register" target="_self">立即注册</a></div>
                <div class="clear"></div>
                <div class="under-line center"></div>
            </div>
            <form id="loginForm" onsubmit="return false;">
                <div class="login_main center">

                    <div class="login-info">用户名:&nbsp;<input class="login-info-input" type="text" name="loginAccount"
                                                             id="loginAccount"
                                                             placeholder="请输入用户名"/>
                    </div>
                    <div class="login-info">密&nbsp;&nbsp;&nbsp;&nbsp;码:&nbsp;<input class="login-info-input"
                                                                                    id="password"
                                                                                    type="password"
                                                                                    name="password"
                                                                                    placeholder="请输入你的密码"/></div>
                    <!--<div class="login-info">-->
                    <!--    验证码:&nbsp;-->
                    <!--    <input class="login-info-input verify-code" type="text" name="verifyCode"-->
                    <!--           placeholder="请输入验证码" id="verifyCode"/>-->
                    <!--</div>-->
                </div>
                <div class="login_submit">
                    <input class="submit" type="submit" onclick="login()" value="立即登录">
                </div>
                <div>
                    <ul style="float: right;margin-top: 80px">
                        <li style="display: inline">
                            <a href="https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=102032423&redirect_uri=http://egomall.shop:8004/oauth2.0/qq/success">
                                <img src="/image/qq.png" alt="">
                            </a>
                        </li>
                        <li style="display: inline">
                            <a href="https://api.weibo.com/oauth2/authorize?client_id=4280652521&response_type=code&redirect_uri=http://egomall.shop:8004/oauth2.0/weibo/success">
                                <img src="/image/weibo.png" alt="">
                            </a>
                        </li>
                        <li style="display: inline">
                            <a href="https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=2021003169634351&scope=auth_user&redirect_uri=http://egomall.shop:8004/oauth2.0/zfb/success">
                                <img src="/image/zfb.png" alt="">
                            </a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<!-- jQuery -->
<script th:src="@{jquery/jquery.min.js}"></script>
<script th:src="@{js/valid.js}"></script>
<script th:src="@{sweetalert/sweetalert.min.js}"></script>
<script type="text/javascript">
    function login() {
        let password = $("#password").val();
        if (!validPassword(password)) {
            swal('请输入正确的密码格式(6-18位字符和数字组合)', {
                icon: "error",
            });
            return false;
        }
        // let verifyCode = $("#verifyCode").val();
        // if (!validLength(verifyCode, 4)) {
        //     swal('请输入正确的验证码', {
        //         icon: "error",
        //     });
        //     return false;
        // }
        //验证
        let params = $("#loginForm").serialize();
        let url = '/logging';
        $.ajax({
            type: 'POST',//方法类型
            url: url,
            data: params,
            success: function (result) {
                if (result.code === 200) {
                    window.location.href = '/index';
                } else {
                    swal(result.msg, {
                        icon: "error",
                    });
                }
            },
            error: function () {
                swal("操作失败", {
                    icon: "error",
                });
            }
        });
    }
</script>
</html>
